#ifndef __ENGINE_CONVERT_included
#define __ENGINE_CONVERT_included

#include <string>
#include <boost/scoped_ptr.hpp>
#include <windows.h>

using namespace std;

namespace Util {

class CConverter {

public :

	static void UTF8_TO_Ascii(const string& utf8_string, string& ascii_string) {

		int i = MultiByteToWideChar(CP_UTF8, 0, utf8_string.c_str(), -1, NULL, 0);      
		boost::scoped_ptr<WCHAR> strSrc(new WCHAR[i+1]);

		MultiByteToWideChar(CP_UTF8, 0, utf8_string.c_str(), -1, strSrc.get(), i);      

		i = WideCharToMultiByte(CP_ACP, 0, strSrc.get(), -1, NULL, 0, NULL, NULL);      
		boost::scoped_ptr<char> szRes(new char[i+1]); 
		WideCharToMultiByte(CP_ACP, 0, strSrc.get(), -1, szRes.get(), i, NULL, NULL);      

		ascii_string = szRes.get();      
	}

	static void Ascii_TO_UTF8(const string& ascii_string, string& utf8_string) {

		int i = MultiByteToWideChar(CP_ACP, 0, ascii_string.c_str(), -1, NULL, 0);      
		boost::scoped_ptr<WCHAR> strSrc(new WCHAR[i+1]);
		MultiByteToWideChar(CP_ACP, 0, ascii_string.c_str(), -1, strSrc.get(), i);      

		i = WideCharToMultiByte(CP_UTF8, 0, strSrc.get(), -1, NULL, 0, NULL, NULL);      
		boost::scoped_ptr<char> szRes(new char[i+1]); 
		WideCharToMultiByte(CP_UTF8, 0, strSrc.get(), -1, szRes.get(), i, NULL, NULL);      

		utf8_string = szRes.get();      
	}
};

}

#endif //__ENGINE_CONVERT_included